696104
@@ -278,7 +278,8 @@
public boolean execute(String sql) throws SQLException {
    */
   public boolean executeAsync(String sql) throws SQLException {
     runAsyncOnServer(sql);
-    if (!stmtHandle.isHasResultSet()) {
+    TGetOperationStatusResp status = waitForResultSetStatus();
+    if (!status.isHasResultSet()) {
       return false;
     }
     resultSet =
@@ -318,6 +319,27 @@
private void runAsyncOnServer(String sql) throws SQLException {
     }
   }
 
+  /**
+   * Poll the result set status by checking if isSetHasResultSet is set
+   * @return
+   * @throws SQLException
+   */
+  private TGetOperationStatusResp waitForResultSetStatus() throws SQLException {
+    TGetOperationStatusReq statusReq = new TGetOperationStatusReq(stmtHandle);
+    TGetOperationStatusResp statusResp = null;
+
+    while(statusResp == null || !statusResp.isSetHasResultSet()) {
+      try {
+        statusResp = client.GetOperationStatus(statusReq);
+      } catch (TException e) {
+        isLogBeingGenerated = false;
+        throw new SQLException(e.toString(), "08S01", e);
+      }
+    }
+
+    return statusResp;
+  }
+
   TGetOperationStatusResp waitForOperationToComplete() throws SQLException {
     TGetOperationStatusReq statusReq = new TGetOperationStatusReq(stmtHandle);
     TGetOperationStatusResp statusResp = null;
